﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CineProwl.Domain.MovieDb
{
    public class Person : BaseMovieDb
    {
        public int id;

        public string name;
        public string[] known_as;
        public string biography;
        public DateTime birthday;
        public string birthplace;
        public string url;
        public Role[] filmography;
        public Image[] profile;

        public CineProwl.Domain.Person ToPerson()
        {
            var person = new CineProwl.Domain.Person();

            person.Biography = biography;
            person.Birthplace = birthplace;
            person.Birthday = birthday;
            person.Filomography = GetRoles();
            person.KnownAs = known_as.ToList();
            person.Name = name;
            person.ProfileImage = GetImageList(profile);
            person.Url = url;

            return person;
        }
        
        private List<CineProwl.Domain.Role> GetRoles()
        {
            var roles = (from r in filmography
                         select new CineProwl.Domain.Role()
                        {
                            Character = r.character,
                            Department = r.department,
                            Job = r.job,
                            MovieDbId = r.id,
                            MovieName = r.name,
                            Profile = r.poster
                        }).ToList();
            return roles;
        }
    }
}
